package com.eastfair.certificate.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 制证订单
 * </p>
 *
 * @author ligang
 * @date 2023-07-07
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CertificateOrderCertificateTypeEnum", description = "证件类型:#{CAR:车证;PEOPLE:人证;POWER:机力车证;OTHER:其他证;-枚举")
public enum CertificateOrderCertificateTypeEnum implements BaseEnum {

    /**
     * CAR="车证"
     */
    CAR("车证"),
    /**
     * PEOPLE="人证"
     */
    PEOPLE("人证"),
    /**
     * POWER="机力车证"
     */
    POWER("机力车证"),
    /**
     * OTHER="其他证"
     */
    OTHER("其他证"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static CertificateOrderCertificateTypeEnum match(String val, CertificateOrderCertificateTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CertificateOrderCertificateTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(CertificateOrderCertificateTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "CAR,PEOPLE,POWER,OTHER", example = "CAR")
    public String getCode() {
        return this.name();
    }

}
